/**
 * 数组去重
 * @param {Array} client 要去重的数据
 * @param {Function} rule 去重规则 默认值：JSON.stringify
 * @returns 去重后的结果
 */
module.exports = function dedupe(client, rule = JSON.stringify) {
  const clone = [];
  const lookup = {};
  for (let i = 0; i < client.length; i++) {
    let elem = client[i];
    let hashed = rule(elem);
    if (!lookup[hashed]) {
      clone.push(elem);
      lookup[hashed] = true;
    }
  }
  return clone;
};
